import React, { Component } from 'react'

export default class RibaoForm extends Component {
	state = {
		name: '',
		content: '',
		question: '',
		summary: ''
	}

	componentDidMount() {
		// console.log(this.props.student)
		this.setState({ ...this.props.student })
	}

	handleInput=(rb,e)=>{
			this.setState({[rb]: e.target.value })
	
		// console.log(e.target.value)

	}

  render() {

		let { closeForm, saveInfo, isUpdate,deleInfo} = this.props
		let { name, content, summary, question }= this.state

    return (
			<div>
				<div className="modal fade in" style={{ display:'block' }}>
					<div className="modal-dialog">
						<div className="modal-content">
							<div className="modal-header">
								<button type="button" className="close" onClick={closeForm}>
									<span>×</span></button>
								<h4 className="modal-title">{ isUpdate ? '修改':'新增'}日报</h4>
							</div>
							<div className="modal-body">
								<div className="form-group">
									<label>姓名：</label>
									<input className='form-control' type='text' value={name} onChange={this.handleInput.bind(null,'name')}/>
									<label>学习内容</label>
									<textarea className="form-control" value={content} onChange={this.handleInput.bind(null,'content')}style={{ overflowY: 'hidden' }}></textarea>
									<label>遇到的问题</label>
									<textarea className="form-control" value={question} onChange={this.handleInput.bind(null,'question')}style={{ overflowY: 'hidden' }}></textarea>
									<label>总结</label>
									<textarea className="form-control" value={summary} onChange={this.handleInput.bind(null, 'summary')}style={{ overflowY: 'hidden' }}></textarea>
								</div>
							</div>
							<div className="modal-footer">
								<button type="button" className="btn btn-default pull-left" onClick={closeForm} >取消</button>
								<button type="button" className="btn btn-primary" onClick={saveInfo.bind(null,this.state)}>保存</button>
							</div>
						</div>
					</div>
				</div>
			</div>

    )
  }
}
